<?php
class FunctionArrayData {
    public static $static = null;
    static function writeArrayData($key, $array){
        if(is_array($array))
        {
            $dbin = ByteBuffer::allocate( count($array) ) ;
            DataUtil::writeBytes( $dbin , $array ) ;
            FunctionData::writeKey($key,$dbin->_array());
        }
    }
    static function getArrayFromDB($key)
    {
        $bin= array();
        $rsbin = FunctionData::readKey($key);
        $dbin = new ByteBuffer($rsbin);
        $bin = DataUtil::readBytes($dbin, count($rsbin));
        return $bin;
    }
     static function write2ArrayData($key, $array){
        if(is_array($array))
        {
            $dbin = ByteBuffer::allocate(54) ;
            FunctionArrayData::write2Bytes( $dbin , $array ) ;
            FunctionData::writeKey($key,$dbin->_array());
        }
    }
    static function get2ArrayFromDB($key)
    {
        $bin= array();
        $rsbin = FunctionData::readKey($key);
        $dbin = new ByteBuffer($rsbin);
        $bin = FunctionArrayData::read2Bytes($dbin,9,6);
        return $bin;
    }
    static function write2Bytes($buffer,$bin){
        if(is_array($bin))
        {
            foreach ($bin as $v1) {
                foreach ($v1 as $v2) {
                    $buffer->putByte($v2);
                }
            }
        }	
    }
    static function read2Bytes($buffer,$rlen,$clen){
		$bytes = Array();
		for($i = 0; $i < $rlen; $i++){
                   for($j = 0; $j < $clen; $j++){
                        $bytes[$i][$j] = $buffer->getByte();
                   }	
		}
		return $bytes;
    }
}
?>